package com.product.magina.wechatserver.controller;

import com.magina.common.exception.BusinessException;
import com.magina.common.response.Response;
import com.product.magina.wechatserver.dao.DsmtPlanCustomerDao;
import com.product.magina.wechatserver.entity.DsmtPlanCustomer;
import com.product.magina.wechatserver.sms.SmsClientSend;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;


@RestController
@RequestMapping(value = "SMS")
@Slf4j
@Api(value = "/SMS", description = "发送短信接口")
public class DsmtSMSController1 {

    public static String url = "http://www.uehyt.com/sms.aspx";
    public static String userid = "1330";
    public static String account = "baoli888";
    public static String password = "baoli888";
    public static String mobile = "17605220341";
    public static String content = "验证码：888888 【优易网】";

    @ApiOperation(value = "获取验证码",notes = "{\"openId\":\"asdasd1\",\n" +
            "\"phone\":\"18556720261\"}")
    @GetMapping(value = "/testSend")
    public Response getSMSVerificationCode() throws BusinessException {
        overage();
        return Response.succeed("sss");
    }

    public Response testXML(){
        String res = "";
        String str = "<?xml version=\"1.0\" encoding=\"utf-8\" ?><returnsms>\n" +
                " <returnstatus>Success</returnstatus>\n" +
                " <message>ok</message>\n" +
                " <remainpoint>13671</remainpoint>\n" +
                " <taskID>5444413</taskID>\n" +
                " <successCounts>1</successCounts></returnsms>";
//        Xml
        return Response.succeed(res);
    }

    public static void main(String[] args) {
//		send();
        // overage();
    }

    public static void send() {
        String send = SmsClientSend.sendSms(url, userid, account, password, mobile, content);
        System.out.println(send);
    }

    public static void overage() {
//        String overage = SmsClientOverage.queryOverage(ProjectConst.SMS_URL, ProjectConst.SMS_USER_ID, ProjectConst.SMS_ACCOUNT, ProjectConst.SMS_PASSWORD);
//        System.out.println(overage);
    }

    @Autowired
    private DsmtPlanCustomerDao dsmtPlanCustomerDao;

    @GetMapping("test")
    public Response test(){
        System.out.println(checkCustomerPhoneStauts + "------------");
        List<DsmtPlanCustomer> lius = dsmtPlanCustomerDao.getDsmtPlanByCustomerCode("441421197008172746");
        return Response.succeed(lius);
    }

    @Value(value = "${globalbutton.check_customer_phone_stauts}")
    private String checkCustomerPhoneStauts;


}
